<?php
session_start();
ob_start();
include_once 'include/common.php';
$core = new core();
$msg_error = "";
if ($core->CheckLogin()) {
    header('Location:zenOrderList.php');
} else {


    if (isset($_POST["submit"])) {
      
        if (empty($_POST['username'])) {
            $msg_error = "Vui lòng nhập user name";
        } else {
            if (empty($_POST['password'])) {
                $msg_error = "Vui lòng nhập user name";
            } else {

                $login = $core->Login();
                if ($login) {
                    header('Location:zenOrderList.php');
                } else {
                    $msg_error = "User name, password chưa đúng, vui lòng thử lại!";
                }
            }
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Zen store</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="ha nguyen, a fully featured, responsive, HTML5, Bootstrap admin template.">
        <meta name="author" content="ha nguyen">

        <!-- The styles -->
        <link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
        <style type="text/css">
            body {
                padding-bottom: 40px;
            }
            .sidebar-nav {
                padding: 9px 0;
            }
        </style>
        <link href="css/bootstrap-responsive.css" rel="stylesheet">
        <link href="css/charisma-app.css" rel="stylesheet">

        <link href='css/jquery.iphone.toggle.css' rel='stylesheet'>

        <link rel="shortcut icon" href="img/favicon.ico">

    </head>

    <body>
        <div class="container-fluid">
            <div class="row-fluid">

                <div class="row-fluid">
                    <div class="span12 center login-header">
                        <h2>Welcome to Zen store</h2>
                    </div><!--/span-->
                </div><!--/row-->

                <div class="row-fluid">
                    <div class="well span5 center login-box">
                        <div class="alert alert-info">
                            <?php
                            if ($msg_error != "") {
                                echo $msg_error;
                            } else {
                                echo "Please login with your Username and Password.";
                            }
                            ?>

                        </div>
                        <form class="form-horizontal" action="" method="post">
                            <input type="hidden" name="submit" value=""/>
                            <fieldset>
                                <div class="input-prepend" title="Username" data-rel="tooltip">
                                    <span class="add-on"><i class="icon-user"></i></span><input autofocus class="input-large span10" name="username" id="username" type="text" value="" />
                                </div>
                                <div class="clearfix"></div>

                                <div class="input-prepend" title="Password" data-rel="tooltip">
                                    <span class="add-on"><i class="icon-lock"></i></span><input class="input-large span10" name="password" id="password" type="password" value="" />
                                </div>
                                <div class="clearfix"></div>

                                <div class="input-prepend">
                                    <label class="remember" for="remember">
                                        <?php
                                        if (!isset($_COOKIE['remember_user'])) {
                                            echo '<input type="checkbox" name="remember_user" id="remember" value="1" />';
                                        } else {
                                            echo '<input type="checkbox" name="remember_user" id="remember" value="1"  checked="checked"/>';
                                        }
                                        ?>

                                        Remember me
                                    </label>
                                </div>
                                <div class="clearfix"></div>

                                <p class="center span5">
                                    <button type="submit" class="btn btn-primary">Login</button>
                                </p>
                            </fieldset>
                        </form>
                    </div><!--/span-->
                </div><!--/row-->
            </div><!--/fluid-row-->

        </div><!--/.fluid-container-->

        <!-- external javascript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->

        <!-- jQuery -->
        <script src="js/jquery-1.7.2.min.js"></script>
        <!-- jQuery UI -->




    </body>
</html>
